<?php

namespace app\admin\model;

use think\Model;

class ImageCategory extends Model
{

    protected $autoWriteTimestamp = true;

    protected $pk = 'category_id';
    public static function getList()
    {
        $where = [];
        $limit = input('get.limit');
        $page = input('get.page');
        if ($search = input('get.category_title')) $where[] = ['category_title', 'like', "%" . $search . "%"];
        $list = self::order('category_id', 'desc')
            ->where($where)
            ->paginate($limit);
        return ['code' => 0, 'data' => $list->items(), 'extend' => ['count' => $list->total(), 'limit' => $limit, 'page' => $page]];
    }

    public static function getAll()
    {
        return self::order('category_id desc')
            ->field(['category_id', 'category_title'])
            ->select()
            ->toArray();
    }
}